| commit | 9e8ff3c207c85d2481a011aacae99cf10d40e929 | [log] [tgz] | 
|---|---|---|
| author | Xin Li <delphij@google.com> | Sat Feb 20 12:26:40 2021 +0000 | 
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Sat Feb 20 12:26:40 2021 +0000 | 
| tree | 9e71b2fb2df83e4bfd8abbc2bfa56c2a09d0118e | |
| parent | a18bac0a2661703eaaa443a0b108973f6fa0e710 [diff] | |
| parent | 757c347bd919c4584650d46d4286a6e6e863c44a [diff] | 
[automerger skipped] Mark ab/7061308 as merged in stage. am: 757c347bd9 -s ours am skip reason: Change-Id I4950cd5b3b71e771b0766c9a1aba3657318c9127 with SHA-1 4a39f58be5 is in history Original change: undetermined MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I59ab2e5e03be6e9afb63a407b56e033f225e2a3b
Header-only library for division via fixed-point multiplication by inverse
On modern CPUs and GPUs integer division is several times slower than multiplication. FXdiv implements an algorithm to replace an integer division with a multiplication and two shifts. This algorithm improves performance when an application performs repeated divisions by the same divisor.
uint32_t, uint64_t, and size_t#include <fxdiv.h> /* Division of array by a constant: reference implementation */ void divide_array_c(size_t length, uint32_t array[], uint32_t divisor) { for (size_t i = 0; i < length; i++) { array[i] /= divisor; } } /* Division of array by a constant: implementation with FXdiv */ void divide_array_fxdiv(size_t length, uint32_t array[], uint32_t divisor) { const struct fxdiv_divisor_uint32_t precomputed_divisor = fxdiv_init_uint32_t(divisor); for (size_t i = 0; i < length; i++) { array[i] = fxdiv_quotient_uint32_t(array[i], precomputed_divisor); } }
Currently working features:
| Platform | uint32_t | uint64_t | size_t | 
|---|---|---|---|
| x86-64 gcc | Works | Works | Works | 
| x86-64 clang | Works | Works | Works | 
| x86-64 MSVC | Works | Works | Works | 
| x86 gcc | Works | Works | Works | 
| x86 clang | Works | Works | Works | 
| x86 MSVC | Works | Works | Works | 
| ARMv7 gcc | Works | Works | Works | 
| ARMv7 clang | Works | Works | Works | 
| ARMv7 MSVC* | Compiles | Compiles | Compiles | 
| ARM64 gcc | Works | Works | Works | 
| ARM64 clang | Works | Works | Works | 
| ARM64 MSVC* | Compiles | Compiles | Compiles | 
| PPC64 gcc | Works | Works | Works | 
| WAsm clang | Works | Works | Works | 
| Asm.js clang | Works | Works | Works | 
| PNaCl clang | Works | Works | Works | 
| CUDA | Untested | Untested | Untested | 
| OpenCL | Untested | Untested | Untested | 
*ARMv7 and ARM64 builds with MSVC are presumed to work, but were only verified to compile successfully